<template>
  <view :data-servermsgid="message.serverMsgId" class="Message_entrys" @click="messageClick">
    <template v-if="message.messageInfo.type === 'Text'">
      <Message :message="message" :belong="belong"></Message>
    </template>
    <template v-else-if="message.messageInfo.type === 'RichLink'">
      <RichLink :belong="belong" :message="message"></RichLink>
    </template>
    <template v-else-if="message.messageInfo.type === 'SysText'">
      <SysText :belong="belong" :message="message"></SysText>
    </template>
    <template v-else-if="message.messageInfo.type === 'Finish'">
      <Finish :belong="belong" :message="message"></Finish>
    </template>
    <template v-else-if="message.messageInfo.type === 'Image'">
      <ImageZy :belong="belong" :message="message"></ImageZy>
    </template>
    <!--		<template v-else-if="message.messageInfo.type === Message_TYPE.Video">-->
    <!--			<VideoMessage :belong="belong" :message="message"></VideoMessage>-->
    <!--		</template>-->
    <view v-else>
      <OtherMessage></OtherMessage>
    </view>
  </view>
</template>
<script>
import Text from './text.vue';
import RichLink from './richlink.vue';
import SysText from './sysText.vue';
import Finish from './finish.vue';
import ImageZy from './image.vue';
import OtherMessage from './other.vue';
import VideoMessage from './video.vue';
import Message from './message.vue';

const Message_TYPE = {
  Text: 'Text',
  Image: 'Image',
  SysText: 'SysText',
  RichLink: 'RichLink',
  Audio: 'Audio',
  Video: 'Video',
  Withdraw: 'Withdraw',
  Finish: 'Finish',
  noReply: 'noReply',
  TransferTreatment: 'TransferTreatment',
  CommodityCard: 'CommodityCard',
  drugPlatform_video: 'drugPlatform_video',
};
export default {
  props: ['message', 'belong', 'zimConfig'],
  components: {
    Text,
    RichLink,
    SysText,
    Finish,
    ImageZy,
    OtherMessage,
    VideoMessage,
    Message
  },
  computed: {},
  data() {
    return {
      audioPlaying: false,
      barShow: false,
      Message_TYPE: null,
    };
  },
  mounted() {
    this.Message_TYPE = Message_TYPE;
  },
  methods: {
    messageClick() {
      const {
        message,
        belong
      } = this;
      const {
        messageInfo
      } = message;
      const type = messageInfo.type;
      const targetMessage = {
        message,
        belong,
        type
      };
      if (messageInfo.type === Message_TYPE.RichLink) {
        this.RichLinkClick({
          message,
          belong
        });
      }
      // if (messageInfo.type === Message_TYPE.CommodityCard) {
      //   this.commodityCardClick({ message, belong });
      // }
      // if (messageInfo.type === Message_TYPE.drugPlatform_video) {
      //   this.drugPlatform_video({ message });
      // }
      // if (messageInfo.type === Message_TYPE.Audio) {
      //   this.AudioClick(targetMessage);
      // }
      if (messageInfo.type === Message_TYPE.Image) {
        this.openImage(targetMessage);
      }
      // if (messageInfo.type === Message_TYPE.Video) {
      //   this.openVideo(targetMessage);
      // }
    },
    openImage(targetMessage) {
      this.$emit('openImage', targetMessage);
    },
    RichLinkClick(targetMessage) {
      this.$emit('openRichLink', targetMessage);
    },
  },
};
</script>
<style lang="scss" scoped>
.Message_entrys {
  flex: 1;
  //overflow: hidden;
}
</style>